package org.service.impl;

import java.util.List;

import org.bean.O2rankrank;

import org.dao.CapableDao;
import org.service.CapableService;
import org.util.PageBean;

public class CapableServiceImpl implements CapableService {
	
	private CapableDao  capabledao;
    private O2rankrank o2rankrank;

	




	@SuppressWarnings("unchecked")
	public PageBean queryForPageCapable(int pageSize, int page) {
		final String hql;
		
		hql = "from O2rankrank o2rank order by o2rank.capable desc ";
		
		int allRow = capabledao.getAllRowCount(hql);
		int totalPage = PageBean.countTotalPage(pageSize, allRow);
		final int offset = PageBean.countOffset(pageSize, page);
		final int length = pageSize;
		final int currentPage = PageBean.countCurrentPage(page);

		
		List<O2rankrank> list = capabledao.queryForPageCapable(hql, offset, length);
		
		PageBean pageBean = new PageBean();
		pageBean.setPageSize(pageSize);
		pageBean.setCurrentPage(currentPage);
		pageBean.setAllRow(allRow);
		pageBean.setTotalPage(totalPage);
		pageBean.setList(list);
		pageBean.init();
		
		return pageBean;
	}
	
	public CapableDao getCapabledao() {
		return capabledao;
	}

	public void setCapabledao(CapableDao capabledao) {
		this.capabledao = capabledao;
	}
	public O2rankrank getO2rankrank() {
		return o2rankrank;
	}

	public void setO2rankrank(O2rankrank o2rankrank) {
		this.o2rankrank = o2rankrank;
	}

}
